<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>申请列表</title>
<style type="text/css">
    .td-indexshow span{cursor: pointer;}
    .wenhao{
        width: 20px; height: 20px; border-radius: 100%; border:#d8d8d8 1px solid; font-size: 12px; display: inline-block;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); color: #999; margin-left: 5px;
    }
    .remark{padding: 3px 5px; border-radius: 5px; border:#d8d8d8 1px solid; font-size: 12px; display: inline-block;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); color: #999; margin-left: 5px;}
    .t-red{color: #c62b26;}
    .t-hui{color:#999 }

    .reasonblank{
        background-color: #f9f9f9; 
        border:#ddd 1px solid; 
        border-bottom: 0px; 
        height: 500px; 
        border-radius: 3px;
        position: fixed;
        width: auto;
        top: 20%;
        right: 100px; 
        display: none;

        padding-bottom: 50px;
    }
    .reasonblank i{position: absolute; right: -10px; top: -22px; font-size: 30px;}
    .reason{height: 500px;      overflow-y: scroll; display: block;}
    
    .reason .input{position: absolute; bottom: 5px; width: 100%;}
    .reason .input span{display: inline-block;}
    .reason .input span.right{width: 10%;}
    .reason .input span.left{width: 85%;}
    .reason li{border-bottom:#ddd 1px solid; list-style: none; padding: 5px 10px; position: relative; cursor: pointer;}
    .reason li:hover{background-color: #fff;}

    .pagefun-shenhe:hover{background-color: #000;}
    
</style>
</head>
<body class="pos-r">

<!-- <div class="ui-loading-block" id="loading">
    <div class="ui-loading-cnt">
        <i class="ui-loading-bright"></i>
        <p>正在加载中...</p>
    </div>
</div> -->

<div >
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> <a _href="welcome.html" class="fun-toindex" href="javascript:;">首页</a> 
        <span class="c-gray en">&gt;</span><a href="product-list.html"> 申请管理</a> 
        <span class="c-gray en">&gt;</span> 申请列表 
        <a class="btn btn-success radius r mr-20 reload" style="line-height:1.6em;margin-top:3px" href="javascript:;" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
        <span class="r" style="margin-top: -2px; box-sizing: border-box;">
            
            <select name="cid1" id="cid1" class="select" style="width: auto; height: 31px; vertical-align: middle;">
                <option value="" selected="">全部分类</option>
            </select>

            <select name="cid2" id="cid2" class="select" style="width: auto; height: 31px; vertical-align: middle;">
                <option value="" selected="">全部分类</option>
            </select>

            <select name="state" id="state" class="select" style="width: auto; height: 31px; vertical-align: middle;">
                <option value="" selected="">审核状态</option>
                <option value="2">不通过</option>
                <option value="1">通过</option>
                <option value="0">等待审核</option>
                <option value="3">已发货</option>
                <option value="5">已确认收货</option>
                <option value="70">已超期</option>
            </select>

            <div style="display:inline-block; width:380px; position:relative;">
                日期范围：
                <input name="time" type="text" id="date-range1" class="input-text datainp" style="width:300px">
                <i class="Hui-iconfont i-close" id="inputclear">&#xe706;</i>
            </div>
    
            <span style="position:relative">
                <input type="text" name="keywords" id="search-input" placeholder="回执、快递单号/货名/手机号/备注/用户名/ID" style="width:250px" class="input-text">
                <i class="Hui-iconfont i-close" id="inputclear">&#xe706;</i>
            </span>

            <button name="" id="search" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
            <button id='export' class="btn btn-success">导出EXCEL</button>
        </span>
    </nav>
    
    <div class="reasonblank" id="reasonblank">
        <i class="icon Hui-iconfont">&#xe60b;</i>
        <div class="reason" >   
                <li>产品日期不符合置换标准。</li>
                <li>产品图片不符合置换标准。</li>
                <li>入口类/药品类/服装类产品现阶段不予置换。</li>
                <li>该产品现阶段不予置换。</li>
                <li>产品描述/日期不详，请重新填写。</li>
                <!-- <li>该产品市场流通程度较低，暂时不予置换。</li> -->
                <li>该产品置换价格与市场现价格不符，请重新修改。</li>
                <!-- <li>该产品数量及其置换价格偏高，务必联系客服调整。</li> -->
                <!-- <li>该产品置换数量较多，请找客服协商并重新填写。</li> -->
                <li>产品置换价格填写有误，请重新填写。</li>
               <!--  <li>该产品市场流通程度较低，置换价格较高，请找客服协商并重新填写。</li>
                <li>该产品市场流通程度较低，置换价格较高且数量较多，请找客服协商并重新填写。</li> -->
                <li>该产品存在过期隐患，请核实之后附清晰照片再来申请置换。</li>
                <li>请标记清楚数量，盒/贴/</li>
                <li>为控制单一产品库存量，此产品现阶段不予置换。</li>
                <!-- <li>该产品市场流通程度较低，请咨询客服具体置换数量。</li> -->
                <li>该产品置换数量少于最低置换标准（5盒/瓶/支）。</li>
                <li>请重新填写，产品售价券数应为</li>
                <li>请提供产品零售价格表，便于审核。</li>
                <li>该产品流通程度较低，暂时不予置换。</li>
            <div class="input">
                <span class="left"><input type="text" class="input-text" value="" id="inputreason" name="inputreason" placeholder="手动输入拒绝理由"></span>
                <span class="right"><button class="btn btn-primary radius" type="button" id="reasonsubmit">提交</button></span>
            </div>
        </div>
    </div>   
        
    <div class="pd-10">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
                <tr class="text-c sort0">
                    <th width="40" class="valueid"><input name="" type="checkbox" value=""></th>
                    <th width="40" class="fun-sort2" data-name="apply_id" data-flag="0">回执ID</th>
                    <th>货物名称</th>
                    <th width="100">申请者</th>
                    <th width="80">分类</th>
                    <th width="60">主题图片</th>
                    <th width="100">售价</th>
                    <th width="60">原价</th>
                    <!-- <th width="60">数量</th> -->
                    
                    <th width="70" class="fun-sort2" data-name="apply_time" data-flag="0">申请时间</th>
                    <th width="70" class="fun-sort2" data-name="check_time" data-flag="0">审核时间</th>
                    <th width="70" class="fun-sort2" data-name="receive_time" data-flag="0">收货时间</th>
                    <th width="70" class="fun-sort2" data-name="goods_adddate" data-flag="0">生产日期</th>
                    <th width="70" class="fun-sort2" data-name="goods_date" data-flag="0">到期日期</th>
                    <th width="120">当前状态</th>
                    
                    <!-- <th width="80">是否上架</th> -->
                    
                    <!-- <th width="60">操作</th> -->
                </tr>
            </thead>
            <tbody id="content_sp">
              
            </tbody>
        </table>    
    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20 mb-20" id="operation"> 
<!--         <a href="javascript:;" class="btn btn-warning l mr-10 mt-5 radius fun-all" data-type="stop"><i class="Hui-iconfont">&#xe6de;</i> 批量关闭</a> 
        <a href="javascript:;" class="btn btn-success l mr-10 mt-5 radius fun-all" data-type="start"><i class="Hui-iconfont">&#xe603;</i> 批量开启</a> 
 -->        <a href="javascript:;" class="btn btn-danger l mr-10 mt-5 radius fun-all" data-type="del"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
        <span class="r pt-5"  style="line-height: 35px;" id="page"></span>
        <span class="r mr-10"  style="line-height: 40px;" id="dataall"></span>  
    </div>
        
</div>
</div>

<!-- 货物列表模版 -->
<script id="test" type="text/html">
    <% for (x in list) { %>
    <tr class="text-c va-m sort1">
        <td class="valueid"><input name="" type="checkbox" value="<%=list[x].apply_id%>"></td>
        <td><%=list[x].apply_id%></td>
        <td class="text-l">
            <a style="text-decoration:none" onClick="_open('货物详情','product-view.html?editid=<%=list[x].apply_id%>','90%','80%',true)" class="ml-5 edit" href="javascript:;" title="编辑"><%=list[x].goods_name%></a>  
        </td>
        <td><%=list[x].user_name%>  ID:<%=list[x].uid%><br><%=list[x].user_mobile%></td>
        <td class="text-l fun-search" data-name="cid2" data-value="<%=list[x].gc_id2%>"><%=list[x].gc_name%></td>
        
    
        <td class="text-l" style=" cursor: pointer;" onClick="_open('图片预览','images-view.html?id=<%=list[x].apply_id%>&from=apply','90%','80%',true)" >
            <img class="pic-thumb" src="/Manage/images/blank.gif" data-lazy="<%=list[x].goods_image%>">
            
        </td>
        <td><%=list[x].goods_quan%> × <%=list[x].goods_num%><%=list[x].goods_unit%><br>
            共 <b><%=list[x].goods_quan * list[x].goods_num%></b> 券
        </td>
        <td>¥ <%=list[x].goods_price%></td>
        <td><%=list[x].apply_time%></td>
        
        <td><%=list[x].check_time%></td>

        <td><%=list[x].receive_time%></td>
        
        <td><%=list[x].goods_adddate%></td>

        <td><%=list[x].goods_date%><br> ( <%=list[x].remain_date%>天 )</td>

        <td class="td-indexshow">
            
            <%if(list[x].apply_state==2){ %>
                <span style="color:#c62b26; cursor: pointer;">审核不通过</span><%if(list[x].reason!==""){%><span class="wenhao" title="<%=list[x].reason%>">?</span><%}%>
            <%}else if(list[x].apply_state==70){%>
                <span>已超期</span>
            <%}else if(list[x].apply_state==1){ %>
                审核通过,等待用户发货<br>
                <span class="label label-success radius" data-flag="5" style="cursor: pointer;" onClick="_open('发货','apply-trans-add.html?order_state=<%=list[x].apply_state%>&aid=<%=list[x].apply_id%>','80%','70%',false)">帮TA填写物流信息</span>

            <%}else if(list[x].apply_state==6){%>
                <span style="color:#c62b26; cursor: pointer;">货物拒收</span><%if(list[x].reason!==""){%><span class="wenhao" title="<%=list[x].reason%>">?</span><%}%>
            <%}else if(list[x].apply_state==0){ %>
                

                <span class="label radius pagefun-shenhe" data-index="<%=x%>" data-flag="1" style="cursor: pointer;">通过</span>
                <span class="label radius pagefun-shenhe" data-index="<%=x%>" data-flag="2" style="cursor: pointer;" title="<%=list[x].reason%>">不通过</span>
            <%}else if(list[x].apply_state==3){ %>
                
                <%=list[x].shipping_name%> <%if(list[x].remark!==""){%><span class="wenhao" title="客户备注：<%=list[x].remark%>">?</span><%}%><br>

                <%
                    var numlist=list[x].shipping_num.split(',')
                    for(j in numlist){
                %>
                 <a style="text-decoration:none" onClick="_open('物流详情','apply-trans-add.html?aid=<%=list[x].apply_id%>&sid=<%=numlist[j]%>&order_state=<%=list[x].apply_state%>','50%','70%',true)" class="ml-5 edit" href="javascript:;" title="查看物流详情"> 
                <%=numlist[j]%><br></a>
                <%}%>
                

                
                <span class="label radius pagefun-shenhe" data-index="<%=x%>" data-flag="5" style="cursor: pointer;">确认收货</span>
                <span class="label radius pagefun-shenhe" data-index="<%=x%>" data-flag="6" style="cursor: pointer;">货物拒收</span>
            <%}else if(list[x].apply_state==5){ %>
                已确认收货
                <%=list[x].shipping_name%><br>
                
                
               
                <%
                    var numlist=list[x].shipping_num.split(',')
                    for(j in numlist){
                %>
                 <a style="text-decoration:none" onClick="_open('物流详情','apply-trans-add.html?aid=<%=list[x].apply_id%>&sid=<%=numlist[j]%>&order_state=<%=list[x].apply_state%>','50%','70%',true)" class="ml-5 edit" href="javascript:;" title="查看物流详情"> 
                <%=numlist[j]%><br></a>
                <%}%>
            <%}else{%>
                <span style="color:#999;" >此信息已被用户删除</span><%if(list[x].reason!==""){%><span class="wenhao" title="<%=list[x].reason%>">?</span><%}%>
            <%}%>
        </td>
        
        <!-- <td class="td-status">
            <%if(list[x].apply_state=='4'){%> 
                <input type="checkbox" class="switch fun-start-stop" style="outline: none;" <%if(list[x].goods_show==1){ %>checked<% }%> />
            <%}else{%>
                
            <%}%>
        </td> -->
        
        <!-- <td class="td-manage f-18">     
            <a style="text-decoration:none" class="ml-5 fun-del" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
            <a style="text-decoration:none" onClick="_open('货物编辑','product-add.html?editid=<%=list[x].apply_id%>','90%','80%',true)" class="ml-5 edit" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
        </td> -->
    </tr>
    <%}%>  
</script> 
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/template-native.js"></script> 
<script type="text/javascript" src="js/s.js"></script> 


<script type="text/javascript" src="lib/laypage/laypage.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<script src="/Manage/js/lazyload.min.js"></script>
<script type="text/javascript">
var API=API_APPLYLIST;
var kk=API_APPLYLIST;
var orderby='';
var search='';


var uid=getUrlParam('uid');//用户详情查询使用
if(uid!==null && uid!==undefined){
    API=API+'?uid='+uid;
    // $("nav").hide();
    // $("#operation").hide();
}
loaddata(API,1,true);
$('#date-range1').dateRangePicker({
    startOfWeek: 'monday',
    separator : ' 至 ',
    format: 'YYYY-MM-DD HH:mm',
    autoClose: true,
    time: {
        enabled: true
    },
    defaultTime: moment().startOf('day').toDate(),
    defaultEndTime: moment().endOf('day').toDate()
});


$(document).ready(function(){ 
    // 物流公司
    for(var i in shippinglist){
        $("#shipping_name").append('<option value="'+shippinglist[i].name+'">'+shippinglist[i].name+'</option>');   
    }

    // 选择拒绝原因
    $(document).on('click','div#reasonblank li',function(){
        var reason=$(this).text();
        
        $("#inputreason").val(reason);
        $("#inputreason").focus();
    })
    // 提交拒绝原因
    $(document).on('click','button#reasonsubmit',function(){
        var id=$("#reasonblank").data("id");
        var flag=$("#reasonblank").data("flag");
        var index=$("#reasonblank").data("index");

        $.getJSON(API_APPLYLIST,{pass:id,state:flag,reason:$("#inputreason").val()},function(data){
            checkStatus(data);
            $("#reasonblank").hide();
            if(flag==6){
                $("#content_sp tr").eq(index).find("td.td-indexshow").html('货物拒收');
            }else if(flag==2){
                $("#content_sp tr").eq(index).find("td.td-indexshow").html('<span style="color:#c62b26">审核不通过</span>');
            }
            $(reasonblank).hide();
    
        })
    })
    // 关闭拒绝列表
    $(document).on('click','#reasonblank i',function(){
        $("#reasonblank").hide();
    })
    
        

    // 货物操作、审核/确认收货、拒收
    $(document).on('click','span.pagefun-shenhe',function(){
        var id=$(this).parent().parent().find("td.valueid:first-child input").val();
        var that=$(this);       
        var flag=that.data("flag");
        var index=that.data("index");
        if(flag==6 || flag==2){

            $("#reasonblank").show();
            $("#inputreason").val("");
            $("#reasonblank").data("id",id);
            $("#reasonblank").data("flag",flag);
            $("#reasonblank").data("index",index);
            
        }else if(flag==5){
            layer.confirm('确认收货后,券将打到用户账户?',function(index){
                $.getJSON(API_APPLYLIST,{pass:id,state:flag},function(data){
                    checkStatus(data);
                    that.parent().html('已确认收货');
                    layer.close(index);
                })
                
            })
        }else{
            $.getJSON(API_APPLYLIST,{pass:id,state:flag},function(data){
                checkStatus(data);
                if(data.status==1){
                    that.parent().html("审核通过，等待用户发货");     
                }
            });  
        }
        
    })

    


    // 筛选列表
    var gc;
    $.getJSON(API_GOODSCLASS,function(data){
        if(!checkStatus(data)) return;

        gc=data.datas;
        if(data==''){
            layer.msg('分类出错', {icon:5,time:1000});
        }else{
            // 罗列一级分类
            for(i=0; i<data.datas.length; i++){
                $("#cid1").append("<option value='"+data.datas[i].gc_id+"' data-flag='"+i+"'>"+data.datas[i].gc_name+"</option>");
            }
            //二级菜单联动
            $("#cid1").change(function () {
                // var ii=$(this).val();
                var tt=$("#cid1").val();
                if(tt==""){
                    $("#cid2").html('<option value="" selected="">全部分类</option>');
                }else{
                    var ii=$('#cid1 option:selected').data("flag");
                    var data2=gc[ii]['child'];
                        $("#cid2").empty();
                        $("#cid2").append("<option value='0' >全部分类</option>");
                    for(j=0; j<data2.length; j++){
                        $("#cid2").append("<option value='"+data2[j].gc_id+"' >"+data2[j].gc_name+"</option>");
                    }
                }
                
            });
        }   
    });


    $("#search").click(function(){
        kk=API+"?";
        var content=encodeURI(document.querySelector('input[name=keywords]').value);
        var param=[
            'k='+encodeURI(document.querySelector('input[name=keywords]').value),
            'cid1='+document.querySelector('select[name=cid1]').value,
            'cid2='+document.querySelector('select[name=cid2]').value,
            't='+document.querySelector('select[name=state]').value,
            'time='+document.querySelector('input[name=time]').value,

        ];
        search=param.join('&');
        kk=kk+search+'&'+orderby;
        loaddata(kk,1);

        
    })

    $(document).on('click','#export',function(){
        var param=[
            'k='+encodeURI(document.querySelector('input[name=keywords]').value),
            'cid1='+document.querySelector('select[name=cid1]').value,
            'cid2='+document.querySelector('select[name=cid2]').value,
            't='+document.querySelector('select[name=state]').value,
            'time='+document.querySelector('input[name=time]').value,
        ];
        param=param.join('&');
        window.open(API_EXPORT_APPLY+'?'+param+'&'+orderby);
        console.log(API_EXPORT_APPLY+'?'+param+'&'+orderby)
    })

    $(document).on('click','td.searchstore',function(){
        var storeid=$(this).data("storeid");
        kk=API+"?sid="+storeid;
        loaddata(kk,1,true);    
    })


    

   
    
    
})





        



</script>
</body>
</html>